Create  proc sp_update_markfg_product_inventory (

@part_number varchar(20), 
@step_name varchar(50),
@track_id int,
@markprocess_step_id int,
@fgprocess_step_id int)

as
begin
    declare @temp_fg_processStep_id int
    declare @temp_test_processStep_id int
    declare @temp_test_step_name varchar(50)

    IF @fgprocess_step_id <> -1 and @fgprocess_step_id <> -2
        BEGIN            
	    update Mark_FG_Track_Table set Product_name = @part_number where AssemblyTrack_ID = @track_id and  FG_ProcessStep_ID = @fgprocess_step_id
	    update product set part_Number = @part_number where processStep_Id = @fgprocess_step_id
  	    update product set part_Number = @part_number where processStep_Id = @markprocess_step_id
	    update inventory_Step_table set IST_Manufacturing_Part_Number = @part_number where processStep_Id = @fgprocess_step_id
        END
    ELSE IF @markprocess_step_id <> -1 and @markprocess_step_id <> -2
        BEGIN	    
	    update Mark_FG_Track_Table set Product_name = @part_number where AssemblyTrack_ID = @track_id and  Mark_Pack_ProcessStep_ID = @markprocess_step_id
	    update product set part_Number = @part_number where processStep_Id = @markprocess_step_id
        END
    ELSE
        BEGIN
	    INSERT INTO Mark_FG_Track_Table (AssemblyTrack_ID, Test_Step_Name, Product_Name, Mark_Pack, Mark_Pack_Status, FG, FG_Status) values(@track_id, @step_name, @part_number, 'Mark & Pack', 'Incomplete', 'FG', 'Incomplete')
        END
end


